<template>
    <el-tree
      :data="treeNode"
      node-key="id"
      :props="defaultProps"
      @node-click="handleNodeClick"
    >
    </el-tree>
</template>

<script>
    export default {
        name: "tree",
      data(){
          return {
            defaultProps:{children:"cateList",label:"name"},
            treeNode:[],
          }
      },
      methods:{
        handleNodeClick(data){
          console.log(data)
        }
      },
      created(){
          this.axios({
            url:"/categories",
            method:"get"
          }).then((resp)=>{
            this.treeNode=resp.data
          });
      }
    }
</script>

<style scoped>

</style>
